package com.weigee.ktv.v.adapter.grid;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.l.d.app.library.adapter.MyListAdapter;
import com.l.d.app.library.util.CalendarUtil;
import com.l.d.app.library.view.FocusedTextView;
import com.weigee.ktv.R;
import com.weigee.ktv.m.entity.WrapHolder;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import butterknife.BindView;

/**
 * Created by linde on 2017/04/19.
 * <p/>
 */

public class SingingTimeListAdapter extends MyListAdapter<Calendar, SingingTimeListAdapter.Holder> {
    @NonNull
    @Override
    protected List<Calendar> onCreateNewEmptyList() {
        return new ArrayList<>();
    }

    @NonNull
    @Override
    protected Holder onCreateViewHolder(int position, ViewGroup parent) {
        final Context context = parent.getContext();
        final View itemView = LayoutInflater.from(context).inflate(R.layout.checksingingtime_frag_grid_item, parent, false);
        return new Holder(itemView);
    }

    @Override
    protected void onBindViewHolder(Holder holder, int position) {
        final Calendar calendar = getItem(position);
        if (calendar == null) {
            return;
        }
        holder.tvTime.setText(CalendarUtil.stringFormat(calendar.getTimeInMillis(), "HH:mm", null));
    }

    static class Holder extends WrapHolder {
        @BindView(R.id.tv_time)
        FocusedTextView tvTime;

        private Holder(View itemView) {
            super(itemView);
        }
    }
}
